﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RRs1305haigla1Request", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RRs1305haigla1Request))]
    public class RRs1305haigla1RequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRRs1305haigla1Request clazz;
        
        public RRs1305haigla1RequestSerializer(IRRs1305haigla1Request clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("ctellimusnr");
            if (clazz.Ctellimusnr!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Ctellimusnr))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Ctellimusnr");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ctlaps_skpv");
            if (clazz.CtlapsSkpv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CtlapsSkpv))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CtlapsSkpv");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("claps_saeg");
            if (clazz.ClapsSaeg!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ClapsSaeg))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ClapsSaeg");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("claps_sugu");
            if (clazz.ClapsSugu!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ClapsSugu))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ClapsSugu");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("cema_ikood");
            if (clazz.CemaIkood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CemaIkood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CemaIkood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("cema_pere");
            if (clazz.CemaPere!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CemaPere))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CemaPere");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("cema_ees");
            if (clazz.CemaEes!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CemaEes))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CemaEes");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("iema_riik");
            if (clazz.IemaRiik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IemaRiik))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IemaRiik");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="ctellimusnr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1305haigla1Request>ctellimusnr");
                }
                clazz.Ctellimusnr = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ctellimusnr")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1305haigla1Request>ctellimusnr", Reader.LocalName);
            }
            if (Reader.LocalName=="ctlaps_skpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1305haigla1Request>ctlaps_skpv");
                }
                clazz.CtlapsSkpv = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ctlaps_skpv")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1305haigla1Request>ctlaps_skpv", Reader.LocalName);
            }
            if (Reader.LocalName=="claps_saeg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1305haigla1Request>claps_saeg");
                }
                clazz.ClapsSaeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("claps_saeg")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1305haigla1Request>claps_saeg", Reader.LocalName);
            }
            if (Reader.LocalName=="claps_sugu") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1305haigla1Request>claps_sugu");
                }
                clazz.ClapsSugu = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("claps_sugu")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1305haigla1Request>claps_sugu", Reader.LocalName);
            }
            if (Reader.LocalName=="cema_ikood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1305haigla1Request>cema_ikood");
                }
                clazz.CemaIkood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cema_ikood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1305haigla1Request>cema_ikood", Reader.LocalName);
            }
            if (Reader.LocalName=="cema_pere") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1305haigla1Request>cema_pere");
                }
                clazz.CemaPere = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cema_pere")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1305haigla1Request>cema_pere", Reader.LocalName);
            }
            if (Reader.LocalName=="cema_ees") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1305haigla1Request>cema_ees");
                }
                clazz.CemaEes = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cema_ees")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1305haigla1Request>cema_ees", Reader.LocalName);
            }
            if (Reader.LocalName=="iema_riik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RRs1305haigla1Request>iema_riik");
                }
                clazz.IemaRiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("iema_riik")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RRs1305haigla1Request>iema_riik", Reader.LocalName);
            }
        }
    }
}
